
local STR_ERROR     = false 
local STR_SUCCESS   = true 



-- 创建strbuf = {}
function new_stringbuf()

    local strbuf = {}
    strbuf.str =''   
    return strbuf
end 

-- 格式化字符串
function strbuf_Vformat(strbuf, format, va_list)

    local str  = string.format(format,table.unpack(va_list))
    strbuf.str = strbuf.str .. str
    return STR_SUCCESS 
end 

-- 格式化字符串        
function strbuf_format(strbuf, format, ...)

    if not strbuf or not format then 
        return STR_ERROR
    end 

    local ap = {...}
    local temp =  string.format(format, table.unpack(ap))
    strbuf.str = strbuf.str .. temp 
    return STR_SUCCESS
end 


-- 拼接
function strbuf_append(strbuf, nstrbuf)

    if not strbuf  or not nstrbuf then
        return STR_ERROR 
    end 

    if strbuf.str  then 
         strbuf.str =  strbuf.str .. nstrbuf.str
    end 

    return STR_SUCCESS
end 

-- 字符串的拼接
function strbuf_append_str(strbuf, format)

    if not strbuf or not format then 
        return  STR_ERROR 
    end 

    strbuf.str = strbuf.str .. format
    return STR_SUCCESS
end 


-- 判断配置文件设置的开关
function config_switch( str )

    if str == "on" or str == "yes" then 
        return true
    end

    if str == "off" or str == "no" then 
        return false 
    end 
    return tonumber(str)
end 


-- 清除 
function strbuf_clear(strbuf)

    if strbuf  then 
        strbuf.str = ''
    end 
end 


-- 销毁
function strbuf_destroy(strbuf)
    
    if strbuf then 
        strbuf = nil
    end 
end 


function str_trim(str, fromat)

  	local _,_,value = string.find(str, format or "%s*(.-)%s*$")
	
    if value then
		return value
	end
end 

-- 解析配置文件(暂不考虑实现)
function sv_read_db(directory, filename, delim,mincols,maxcols, maxrows, func)
end 

-- function start()
-- end

